package com.tedu.sp06;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableCircuitBreaker
public class Sp06RibbonApplication {

    @Bean
    @LoadBalanced//实现负载均衡
    public RestTemplate getRestTemplate(){
        SimpleClientHttpRequestFactory s = new SimpleClientHttpRequestFactory();
        //两个超时参数默认是-1，表示不启用
        s.setConnectTimeout(1000);
        s.setReadTimeout(1000);
        RestTemplate restTemplate = new RestTemplate(s);
        return restTemplate;
    }
    public static void main(String[] args) {
        SpringApplication.run(Sp06RibbonApplication.class, args);
    }

}
